from osv import osv, fields
import pooler

from tools import config
from tools.translate import _

class account_budget_post(osv.osv):
    _name = 'account.budget.post'
    _description = 'Budgetary Position'
    _inherit='account.budget.post'
    
    def search(self, cr, user, args, offset=0, limit=None, order=None,  context=None, count=False):
        if context:
            if 'project_id' in context.keys():
                prj_id = context['project_id']
                if prj_id:
                    cr.execute("Select Distinct\
                                    budget_id\
                                from\
                                    kdvn_budget_data kbd\
                                where kbd.project_id=%s" % prj_id)
                    res = cr.fetchall()
                    res1=[]
                    for tmp in res:
                        res1.append(tmp[0])
                    var_filter=res1
                    args.append(('id','in',var_filter))
                else:
                    args.append(('id','in',[]))
        return super(account_budget_post,self).search(cr, user, args, offset, limit, order,context, count)
account_budget_post()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
